- main_toolbar do |t|
  = t.edit resource
  = t.destroy
  = t.new(params: {controller: :issues, target_id: resource.id, target_type: resource.class.name}, tool: 'new-issue')

= main_informations attachment: true do
  = render 'picture'
  = infos do
    -#
      .med-info.important
        - icon = resource.category.pictogram
        %span.title= Matter.human_attribute_name(:variant)
        %span.value
          %i.picto{class: "picto-#{icon}"}
          = link_to(resource.variant_name, controller: :product_nature_variants, action: :show, id: resource.variant_id)
    = product_info(:work_number, important: true)
    - if resource.born_at and resource.age >= 1.day
      .med-info
        %span.title= Matter.human_attribute_name(:age)
        %span.value
          %i.picto{class: "picto-clock-o"}
          = human_age(resource.born_at, display: 3)
    - unless resource.population_counting_unitary?
      = product_info :population, important: true do |population|
        = population.l + " " + resource.unit_name
      - if resource.has_indicator?(:net_mass)
        = product_info(:net_mass, important: true)
      - if resource.current_ownership && resource.current_ownership.other?
        = product_info(:owner, important: true) do |owner|
          = owner.name
      - if resource.incoming_parcel_item
        .med-info.important
          %span.title= :incoming_parcels.tl
          %span.value
            %i.picto{class: "picto-movements"}
            = link_to(resource.incoming_parcel_item.parcel.number, controller: :parcels, action: :show, id: resource.incoming_parcel_item.parcel.id)
      - if resource.outgoing_parcel_item
        .med-info.important
          %span.title= :outgoing_parcels.tl
          %span.value
            %i.picto{class: "picto-movements"}
            = link_to(resource.outgoing_parcel_item.parcel.number, controller: :parcels, action: :show, id: resource.outgoing_parcel_item.parcel.id)
  = labels_info(resource.labels)

= cobbles do |c|
  - if resource.is_a?(ProductGroup)
    - c.cobble(:members) do
      = cobble_list(:members)
  - if resource.groups.any?
    - c.cobble(:groups) do
      = cobble_list(:groups)

  - c.cobble(:variable_indicators) do
    = variable_readings(resource)

  - c.cobble(:parcel_items) do
    = cobble_list(:parcel_items)

  -# c.cobble(tl(:x_readings, count: resource.readings.count)) do
    = cobble_list(:readings)

  - count = 0
  - map = visualization do |v|
    - if resource.container
      - shape = resource.container.shape
      - if shape
        - v.serie resource.container.id, [{name: resource.container.name, shape: shape}]
        - v.simple resource.container.name , resource.container.id, fill_color: cycle(theme_colors)
        - count += 1
    - v.control :zoom
    - v.control :scale
    - v.control :fullscreen
    - v.control :layer_selector
  - if count > 0
    - c.cobble :container do
      = map
  - c.cobble(:intervention_product_parameters, title: :x_interventions.tl(count: resource.interventions.count)) do
    = cobble_list(:intervention_product_parameters)
  - c.cobble(:issues) do
    = cobble_toolbar do |t|
      = t.new(params: {controller: :issues, :target_id => resource.id, :target_type => resource.class.name})
    = cobble_list(:issues)

= render "timeline"
